local skel = fk.CreateSkill {
  name = "rmt__yiyan",
}

Fk:loadTranslationTable{
  ["rmt__yiyan"] = "易演",
  [":rmt__yiyan"] = "攻击范围内有你的角色回合开始时，你可以重铸一张黑色牌然后卜算2，或卜算2然后可以重铸一张红色牌。",

  ["#rmt__yiyan-ask"] = "现在是 %src 的回合开始，你可以发动“易演”进行卜算",
  ["#rmt__yiyan-black"] = "易演：重铸1张黑色牌然后卜算2；或者先卜算2",
  ["#rmt__yiyan-red"] = "易演：你可以重铸1张红色牌",
}

skel:addEffect(fk.TurnStart, {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and target:inMyAttackRange(player)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    if not room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#rmt__yiyan-ask:"..target.id }) then return false end
    local cards = room:askToCards(player, {
      skill_name = skel.name, prompt = "#rmt__yiyan-black", pattern = ".|.|spade,club", max_num = 1, min_num = 1,
      include_equip = true, cancelable = true,
    })
    event:setCostData(self, { cards = cards })
    return true
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local cards = event:getCostData(self).cards or {}
    if #cards == 0 then
      room:askToGuanxing(player, { skill_name = skel.name, cards = room:getNCards(2) })
      cards = room:askToCards(player, {
        skill_name = skel.name, prompt = "#rmt__yiyan-red", pattern = ".|.|diamond,heart", max_num = 1, min_num = 1,
        include_equip = true, cancelable = true,
      })
      if #cards == 0 then return end
      room:recastCard(cards, player, skel.name)
    else
      room:recastCard(cards, player, skel.name)
      if player.dead then return end
      room:askToGuanxing(player, { skill_name = skel.name, cards = room:getNCards(2) })
    end
  end,
})


return skel
